/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tecbooks;

import java.awt.Color;
import javax.swing.JOptionPane;

/**
 *
 * @author Taciane
 */
public class RenovacaoLocacao extends javax.swing.JFrame {

    /**
     * Creates new form RenovacaoLocacao
     */
    public RenovacaoLocacao() {
        setTitle("Renovação de Locação");
        this.getContentPane().setBackground(Color.pink);
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblIdClienteRenovacao = new javax.swing.JLabel();
        lblIdlivroRenovacao = new javax.swing.JLabel();
        lblIdDataRenovacao = new javax.swing.JLabel();
        lblIdnewDataRenovacao = new javax.swing.JLabel();
        txtIdCliente = new javax.swing.JTextField();
        txtIdLivro = new javax.swing.JTextField();
        cmbDiaEntrega = new javax.swing.JComboBox();
        cmbMesEntrega = new javax.swing.JComboBox();
        cmbAnoEntrega = new javax.swing.JComboBox();
        cmbDiaEntrega1 = new javax.swing.JComboBox();
        cmbMesEntrega1 = new javax.swing.JComboBox();
        cmbAnoEntrega1 = new javax.swing.JComboBox();
        btnOkData = new javax.swing.JButton();
        btnCancelarData = new javax.swing.JButton();
        lblAvisoRenovacao = new javax.swing.JLabel();
        lblAvisoIdCliente = new javax.swing.JLabel();
        lblAvisoIdLivro = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(0, 0, 0));
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setForeground(new java.awt.Color(102, 255, 255));

        lblIdClienteRenovacao.setText("ID do Cliente*:");

        lblIdlivroRenovacao.setText("ID do Livro*:");

        lblIdDataRenovacao.setText("Data de entrega(dd/mm/aaaa)*:");

        lblIdnewDataRenovacao.setText("Nova data de entrega(dd/mm/aaaa)*:");

        txtIdCliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtIdClienteKeyTyped(evt);
            }
        });

        txtIdLivro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtIdLivroKeyTyped(evt);
            }
        });

        cmbDiaEntrega.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        cmbMesEntrega.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" }));

        cmbAnoEntrega.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));

        cmbDiaEntrega1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        cmbMesEntrega1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" }));

        cmbAnoEntrega1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));

        btnOkData.setText("OK");
        btnOkData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkDataActionPerformed(evt);
            }
        });

        btnCancelarData.setText("CANCELAR");
        btnCancelarData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarDataActionPerformed(evt);
            }
        });

        lblAvisoRenovacao.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblAvisoRenovacao.setForeground(new java.awt.Color(255, 0, 0));

        lblAvisoIdCliente.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblAvisoIdCliente.setForeground(new java.awt.Color(255, 0, 0));

        lblAvisoIdLivro.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblAvisoIdLivro.setForeground(new java.awt.Color(255, 0, 0));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(19, 19, 19)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblIdDataRenovacao)
                                    .addComponent(lblIdnewDataRenovacao)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(lblIdClienteRenovacao)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtIdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(lblIdlivroRenovacao)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtIdLivro, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(81, 81, 81)
                                .addComponent(cmbDiaEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(cmbMesEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(cmbAnoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(btnOkData)
                                        .addGap(44, 44, 44)
                                        .addComponent(btnCancelarData))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(cmbDiaEntrega1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(cmbMesEntrega1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(cmbAnoEntrega1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addComponent(lblAvisoIdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(lblAvisoRenovacao, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(53, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(lblAvisoIdLivro, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(63, 63, 63))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblIdClienteRenovacao)
                    .addComponent(txtIdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblAvisoIdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblIdlivroRenovacao)
                    .addComponent(txtIdLivro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addComponent(lblAvisoIdLivro, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblIdDataRenovacao)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbDiaEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbMesEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbAnoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addComponent(lblIdnewDataRenovacao)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbDiaEntrega1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbMesEntrega1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbAnoEntrega1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnOkData)
                    .addComponent(btnCancelarData))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblAvisoRenovacao, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCancelarDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarDataActionPerformed
        dispose();
        TelaPrincipal tela = new TelaPrincipal();
        tela.setVisible(true);        // TODO add your handling code here:
    }//GEN-LAST:event_btnCancelarDataActionPerformed

    private void btnOkDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkDataActionPerformed
  if (txtIdLivro.getText().isEmpty() || txtIdCliente.getText().isEmpty() || cmbDiaEntrega.getSelectedItem().equals("  ") ||
             cmbDiaEntrega1.getSelectedItem().equals("  ")||cmbMesEntrega.getSelectedItem().equals("  ")||cmbMesEntrega1.getSelectedItem().equals("  ")
             ||cmbAnoEntrega.getSelectedItem().equals("  ")||cmbAnoEntrega1.getSelectedItem().equals("  ")) {
            lblAvisoRenovacao.setText("Preencha os campos obrigatórios!");
            
        } else {
            JOptionPane.showMessageDialog(null, "Renovação de locação realizada!");        // TODO add your handling code here:
     }        // TODO add your handling code here:
    }//GEN-LAST:event_btnOkDataActionPerformed

    private void txtIdClienteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtIdClienteKeyTyped
       String numeros = "0123456789";
        if(!numeros.contains(evt.getKeyChar()+"") && (int)evt.getKeyChar() != 8){
            evt.consume();
            lblAvisoIdCliente.setText("Por favor, informe apenas números!");
        }
        else{
           lblAvisoIdCliente.setText("");
        }        // TODO add your handling code here:
    }//GEN-LAST:event_txtIdClienteKeyTyped

    private void txtIdLivroKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtIdLivroKeyTyped
      String numeros = "0123456789";
        if(!numeros.contains(evt.getKeyChar()+"") && (int)evt.getKeyChar() != 8){
            evt.consume();
            lblAvisoIdLivro.setText("Por favor, informe apenas números!");
        }
        else{
           lblAvisoIdLivro.setText("");
        }        // TODO add your handling code here:
    }//GEN-LAST:event_txtIdLivroKeyTyped

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(RenovacaoLocacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(RenovacaoLocacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(RenovacaoLocacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(RenovacaoLocacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new RenovacaoLocacao().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelarData;
    private javax.swing.JButton btnOkData;
    private javax.swing.JComboBox cmbAnoEntrega;
    private javax.swing.JComboBox cmbAnoEntrega1;
    private javax.swing.JComboBox cmbDiaEntrega;
    private javax.swing.JComboBox cmbDiaEntrega1;
    private javax.swing.JComboBox cmbMesEntrega;
    private javax.swing.JComboBox cmbMesEntrega1;
    private javax.swing.JLabel lblAvisoIdCliente;
    private javax.swing.JLabel lblAvisoIdLivro;
    private javax.swing.JLabel lblAvisoRenovacao;
    private javax.swing.JLabel lblIdClienteRenovacao;
    private javax.swing.JLabel lblIdDataRenovacao;
    private javax.swing.JLabel lblIdlivroRenovacao;
    private javax.swing.JLabel lblIdnewDataRenovacao;
    private javax.swing.JTextField txtIdCliente;
    private javax.swing.JTextField txtIdLivro;
    // End of variables declaration//GEN-END:variables
}
